package LeetCode.month04.day93;

import java.util.Arrays;

/**
 * @author 16778
 * @date 2025/11/2 10:34
 * @description
 */
public class No2257 {
    static void main() {
        System.out.println(countUnguarded(4, 6, new int[][]{{0, 0}, {1, 1}, {2, 3}}, new int[][]{{0, 1}, {2, 2}, {1, 4}}));
    }
    public static int countUnguarded(int m, int n, int[][] guards, int[][] walls) {
        int res = 0;
        int [][] dir = new int[][]{{-1,0},{1,0},{0,1},{0,-1}};
        int[][] visited = new int[m][n];
        for (int[] wall : walls) {
            visited[wall[0]][wall[1]]=-1;
        }
        for (int[] guard : guards) {
            visited[guard[0]][guard[1]]=-1;
        }
        for (int[] guard : guards) {
            int x = guard[0];
            int y = guard[1];
            for (int i = 0; i < dir.length; i++) {
                int row = x+dir[i][0];
                int col = y+dir[i][1];
                while(row>=0&&row<m&&col>=0&&col<n&&visited[row][col]!=-1){
                    visited[row][col]=1;
                    row+=dir[i][0];
                    col+=dir[i][1];
                }
            }
        }
        for (int[] ints : visited) {
            System.out.println(Arrays.toString(ints));
        }
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if(visited[i][j]==0){
                    res++;
                }
            }
        }
        return res;
    }
}
